package net.martinimix.bizact.order;

import com.bluemartini.database.DBUtil;
import com.bluemartini.dna.BMException;
import com.bluemartini.dna.BusinessObject;
import com.bluemartini.dna.DNAList;
import com.bluemartini.server.BusinessAction;
import com.bluemartini.util.AttributeUtil;

/**
 * Updates the order header in the given DNAList.
 * 
 * @author Scott Rossillo
 *
 */
public final class UpdateOrderHeader extends BusinessAction {
	
	/**
	 * Creates a new update order header business action.
	 */
	public UpdateOrderHeader() {
		super();
	}

	public DNAList execute(DNAList dnaIn) throws BMException {
		
		final BusinessObject order = dnaIn.removeBusinessObject("ORDER");
		final DNAList response = new DNAList();
		
		DBUtil.updateBusinessObject(order, true);
		AttributeUtil.storeObjectAttributes(order);
		response.setBusinessObjectRef("ORDER", order);
		
		return response;
	}

}
